home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGSCAL / INLINE.LZH / INLINE.DOC < prev    next >
Text File  |  1986-11-13  |  13KB  |  397 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.                                                      November 13, 1986
  9.  
  10.                                 INLINE ASSEMBLER
  11.                                   Version 2.11
  12.  
  13.  
  14.         OVERVIEW
  15.  
  16.         INLINE.COM is an assembler designed to produce Inline 8086/8088 
  17.         and 8087 code for Turbo Pascal (tm) version 3 programs.  Like 
  18.         other assemblers, INLINE accepts as input an assembly language 
  19.         source file and produces an object file.  However, in this case, 
  20.         the 'object' file is an ASCII file consisting of Inline 
  21.         statements which may be inserted into the Turbo Pascal program.
  22.  
  23.         Figure 1 illustrates a Pascal function with Inline code generated 
  24.         by INLINE using the source file of Figure 2.
  25.  
  26.  
  27.         LOADING AND RUNNING INLINE
  28.  
  29.         First create a COM file, INLINE.COM, by compiling INLINE.PAS 
  30.         using the Turbo Pascal compiler.  The normal default memory 
  31.         settings are suitable.
  32.  
  33.         INLINE is called at the DOS prompt with two filename parameters 
  34.         specifying the names of the source and object files.  If no 
  35.         extensions are given, .ASM and .OBJ are used by default.  For 
  36.         instance,
  37.  
  38.           INLINE ABC DEF
  39.  
  40.         will cause INLINE to look for a source file, ABC.ASM, and create 
  41.         an object file, DEF.OBJ.  Files with no extension may be input or 
  42.         created by using a simple '.' for the extension.
  43.  
  44.         If the object filename is missing from the command line, an OBJ 
  45.         file will be created using the same name as the source file.  If 
  46.         neither filename is specified, then names will be requested once 
  47.         execution starts.
  48.  
  49.         Once execution begins, INLINE will run to completion with the 
  50.         only console output being error messages.
  51.  
  52.  
  53.         SYNTAX
  54.  
  55.         The appendix lists the mnemonics accepted by INLINE.  Syntax and 
  56.         mnemonics correspond to that used by most assemblers but note 
  57.         should be made of the following:
  58.  
  59.  
  60.  
  61.  
  62.                                    1
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.           1. Turbo Pascal symbols may be used within instruction entries 
  75.              by preceding the symbol with a '>' (16 bit symbol) or a '<' 
  76.              (8 bit symbol).  The characters '+' and '-' are considered 
  77.              part of the symbol.  This allows computations using symbols 
  78.              to be passed on to the compiler where the computation can be 
  79.              made.  For instance, in
  80.  
  81.                  MOV AX,[>SYMBOL+4]       ;'>SYMBOL+4' is passed on
  82.                  MOV AX,[BP+>SYMBOL+4]    ;again '>SYMBOL+4' is passed on
  83.                  MOV AX,>SYMBOL+4[BP]     ;also acceptable
  84.  
  85.              Note that
  86.  
  87.                  MOV AX,[>SYMBOL+4+BP]
  88.  
  89.              is not correct since the wrong instruction will be generated 
  90.              and '>SYMBOL+4+BP' will be passed on.
  91.  
  92.           2. Labels (for use with jump instructions) may be defined 
  93.              simply by appending a ':' to the first item on a line.  
  94.              Avoid using CS:, DS:, ES:, and SS: as labels, as these 
  95.              specify segment overrides.
  96.  
  97.           3. Numerical entries are assumed to be decimal unless preceded 
  98.              by a '$' indicating a hexadecimal entry.  Characters within 
  99.              single quotes may be used for numerical entries as:
  100.  
  101.                  CMP AL,'a'
  102.  
  103.           4. Square brackets are used to indicate 'contents of'.  If no 
  104.              square brackets are used, an immediate operand is assumed.
  105.  
  106.                  MOV AX,[>DATA]  ;Load AX with the contents of DATA.
  107.                  MOV AX,>DATA    ;Load AX with DATA.
  108.  
  109.           5. Instruction prefixes and segment override prefixes may 
  110.              precede the instruction on the same line or may be included 
  111.              on a previous line.  A colon is optional after the segment 
  112.              prefix.
  113.  
  114.                  ES: MOV AX,[1234]    ;ok
  115.                  REPNE MOVSB          ;ok
  116.                  MOV AX,ES:[1234]     ;incorrect syntax for INLINE
  117.  
  118.           6. Comments may be included in the source.  They are delimited 
  119.              by a ';'.
  120.  
  121.           7. Instructions which don't clearly specify the data size 
  122.              require that BYTE PTR, WORD PTR, DWORD PTR, QWORD PTR, or 
  123.              TBYTE PTR be used.  These may be abbreviated by using the 
  124.              first two letters.
  125.  
  126.  
  127.  
  128.                                    2
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.                  INC BYTE PTR [>BDATA]
  141.                  DEC WO >WARRAY[DI]
  142.                  FLD QWORD [>DBL_REAL]
  143.  
  144.           8. JMP instructions may use SHORT, NEAR, or FAR (they should 
  145.              not be abbreviated).  In the absence of one of these words, 
  146.              a SHORT jump will be encoded if the label is already defined 
  147.              and is within range.  If the label is not defined, a NEAR 
  148.              JMP will be encoded unless SHORT is used.
  149.  
  150.              A FAR CALL or JMP may be made to a direct address by stating 
  151.              both the segment and offset separated by a colon.
  152.  
  153.                  CALL FAR $1234:$5678
  154.  
  155.  
  156.         Normally INLINE generates only one Inline statement per source 
  157.         file.  However, the 'NEW' pseudo-instruction may be used to 
  158.         terminate one Inline statement and begin another.  Using the NEW 
  159.         instruction, it is possible to create a number of Inline 
  160.         statements from one source file.
  161.  
  162.  
  163.         FLOATING POINT INSTRUCTIONS
  164.  
  165.         An automatic WAIT (FWAIT) opcode is generated for each floating 
  166.         point instruction except for the 'no wait' instructions (those 
  167.         with 'N' for the second letter.  However, the WAIT instruction 
  168.         may be required before a floating point instruction having a 
  169.         segment override to insure the WAIT is properly positioned.
  170.  
  171.                WAIT
  172.                ES:FMUL DWORD [BX]
  173.  
  174.  
  175.         RESTRICTIONS
  176.  
  177.         The object file is limited to 32k.  This includes comments and 
  178.         spaces.
  179.  
  180.         Symbols (including any addons from + and -) are limited to 32 
  181.         characters.
  182.  
  183.         Labels may be used in jump statements only and not as data 
  184.         references.  While there is a DB pseudo-opcode, it is not very 
  185.         useful with this restriction.
  186.  
  187.         The number of statement labels that may be defined is limited 
  188.         only by the heap space available.
  189.  
  190.  
  191.  
  192.  
  193.  
  194.                                    3
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.         VERSIONS
  207.  
  208.         2.00 Added 8087 instructions.
  209.         2.01 Fixed bug which wiped out INT $A vector.
  210.         2.02 Fixed bug which prevented labels from starting with BY, WO, 
  211.              DW, QW, and TB.
  212.         2.1  Add NEW pseudo-instruction.  Fixed bug which occurred with 
  213.              filenames having no extension.  Other bugs fixed, notably 
  214.              those effecting IN and OUT.
  215.         2.11 Calculate restricted range for short jumps correctly.
  216.              Fix bug so CALL/JMP <register> may be used.
  217.  
  218.  
  219.         (C) Copyright 1985,86 by L. David Baldwin.
  220.  
  221.         INLINE may be copied and distributed freely providing that no fee 
  222.         is charged and it is not part of a package for which a charge is 
  223.         made.
  224.  
  225.         Please report all bugs, suggestions, and problems to Dave 
  226.         Baldwin, CompuServe ID #76327,53.
  227.  
  228.              22 Fox Den Rd., (Summer)     144 13th St. East,  (Winter)
  229.              Hollis, NH 03049             Tierra Verde, FL 33715
  230.              (603) 465-7857               (813) 867-3030
  231.  
  232.  
  233.              Turbo Pascal is a trademark of Borland International Inc.
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.                                    4
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.         FUNCTION SCAN(LIMIT :INTEGER; CH :CHAR; VAR T ): INTEGER;
  273.         {SCAN LIMIT CHARACTERS FOR CH. RETURN THE NUMBER OF CHARACTERS
  274.          SKIPPED TO FIND A MATCH.  IF NOT FOUND, RETURN RESULT=LIMIT.
  275.          LIMIT MAY BE NEGATIVE FOR A BACKWARDS SCAN.}
  276.         BEGIN    {SCAN MUST BE FAST--USE ASSEMBLY LANGUAGE}
  277.         Inline(
  278.           $FC             {    CLD              ;ASSUME FORWARD}
  279.           /$8A/$46/<CH    {    MOV AL,<CH[BP]   ;CHAR TO SEARCH FOR}
  280.           /$8B/$4E/<LIMIT {    MOV CX,<LIMIT[BP];BYTES TO SEARCH}
  281.           /$09/$C9        {    OR CX,CX         ;CHECK SIGN}
  282.           /$9C            {    PUSHF            ;SAVE FLAGS}
  283.           /$79/$03        {     JNS X1}
  284.           /$F7/$D9        {    NEG CX           ;MAKE POSITIVE}
  285.           /$FD            {    STD              ;BUT SEARCH IN REVERSE}
  286.           /$89/$CA        {X1: MOV DX,CX        ;SAVE FULL COUNT}
  287.           /$C4/$7E/<T     {    LES DI,<T[BP]    ;PTR TO START}
  288.           /$F2/$AE        {    REPNE: SCASB     ;SEARCH}
  289.           /$75/$01        {     JNE X2}
  290.           /$41            {    INC CX           ;FOUND A MATCH}
  291.           /$29/$CA        {X2: SUB DX,CX        ;FIND COUNT TO MATCH}
  292.           /$9D            {    POPF}
  293.           /$79/$02        {     JNS X3}
  294.           /$F7/$DA        {    NEG DX           ;MAKE NEGATIVE IF REVERSE}
  295.           /$89/$56/$0C    {X3: MOV [BP+$C],DX   ;PUT IN FUNCTION RESULT}
  296.         );
  297.         END;
  298.  
  299.                    Figure 1: Pascal Function using Inline Code
  300.  
  301.  
  302.             CLD              ;ASSUME FORWARD
  303.             MOV AL,<CH[BP]   ;CHAR TO SEARCH FOR
  304.             MOV CX,<LIMIT[BP];BYTES TO SEARCH
  305.             OR CX,CX         ;CHECK SIGN
  306.             PUSHF            ;SAVE FLAGS
  307.              JNS X1
  308.             NEG CX           ;MAKE POSITIVE
  309.             STD              ;BUT SEARCH IN REVERSE
  310.         X1: MOV DX,CX        ;SAVE FULL COUNT
  311.             LES DI,<T[BP]    ;PTR TO START
  312.             REPNE: SCASB     ;SEARCH
  313.              JNE X2
  314.             INC CX           ;FOUND A MATCH
  315.         X2: SUB DX,CX        ;FIND COUNT TO MATCH
  316.             POPF
  317.              JNS X3
  318.             NEG DX           ;MAKE NEGATIVE IF REVERSE
  319.         X3: MOV [BP+$C],DX   ;PUT IN FUNCTION RESULT
  320.  
  321.                           Figure 2:  INLINE Input File
  322.  
  323.  
  324.  
  325.  
  326.                                    5
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.         APPENDIX
  341.  
  342.           8086/8088 Opcode Mnemonics Recognized by INLINE
  343.  
  344.                 AAA       HLT       JNE       LOOPNZ    ROR    
  345.                 AAD       IDIV      JNG       LOOPZ     SAHF   
  346.                 AAM       IMUL      JNGE      MOV       SAL    
  347.                 AAS       IN        JNL       MOVSB     SAR    
  348.                 ADC       INC       JNLE      MOVSW     SBB    
  349.                 ADD       INT       JNO       MUL       SCASB  
  350.                 AND       INTO      JNP       NEG       SCASW  
  351.                 CALL      IRET      JNS       NOP       SHL    
  352.                 CBW       JA        JNZ       NOT       SHR    
  353.                 CLC       JAE       JO        OR        SS     
  354.                 CLD       JB        JP        OUT       STC    
  355.                 CLI       JBE       JPE       POP       STD    
  356.                 CMC       JC        JPO       POPF      STI    
  357.                 CMP       JCXZ      JS        PUSH      STOSB  
  358.                 CMPSB     JE        JZ        PUSHF     STOSW  
  359.                 CMPSW     JG        LAHF      RCL       SUB    
  360.                 CS        JGE       LDS       RCR       TEST   
  361.                 CWD       JL        LEA       REP       WAIT   
  362.                 DAA       JLE       LES       REPE      XCHG   
  363.                 DAS       JMP       LOCK      REPNE     XLAT   
  364.                 DB        JNA       LODSB     REPNZ     XOR    
  365.                 DEC       JNAE      LODSW     REPZ   
  366.                 DIV       JNB       LOOP      RET    
  367.                 DS        JNBE      LOOPE     RETF   
  368.                 ES        JNC       LOOPNE    ROL    
  369.  
  370.  
  371.           8087 Opcode Mnemonics Recognized by INLINE
  372.  
  373.                 F2XM1     FDIVRP    FLD       FNOP      FSTP   
  374.                 FABS      FENI      FLD1      FNSAVE    FSTSW  
  375.                 FADD      FFREE     FLDCW     FNSTCW    FSUB   
  376.                 FADDP     FIADD     FLDENV    FNSTENV   FSUBP  
  377.                 FBLD      FICOM     FLDL2E    FNSTSW    FSUBR  
  378.                 FBSTP     FICOMP    FLDL2T    FPATAN    FSUBRP 
  379.                 FCHS      FIDIV     FLDLG2    FPREM     FTST   
  380.                 FCLEX     FIDIVR    FLDLN2    FPTAN     FXAM   
  381.                 FCOM      FILD      FLDPI     FRNDINT   FXCH   
  382.                 FCOMP     FIMUL     FLDZ      FRSTOR    FXTRACT
  383.                 FCOMPP    FINCSTP   FMUL      FSAVE     FYL2X  
  384.                 FDECSTP   FINIT     FMULP     FSCALE    FYL2XP1
  385.                 FDISI     FIST      FNCLEX    FSQRT     FWAIT  
  386.                 FDIV      FISTP     FNDISI    FST    
  387.                 FDIVP     FISUB     FNENI     FSTCW  
  388.                 FDIVR     FISUBR    FNINIT    FSTENV 
  389.  
  390.  
  391.  
  392.                                    6
  393.  
  394.  
  395.  
  396.  
  397.